package engine.message;

import java.util.ArrayDeque;

public class MessageQueue {
	public MessageQueue(Class<?> messageFamily) {
		if(messageFamily == null) {
			throw new NullPointerException();
		}
		MessageFamily = messageFamily;
		_Messages = new ArrayDeque<Message_A>();
	}
	public final Class<?> MessageFamily;
	public boolean accepts(Message_A message) {
		if(message == null) {
			return false;
		} else {
			return(MessageFamily.isInstance(message));
		}
		
	}

	public boolean push(Message_A message) {
		return _Messages.offer(message);
	}
	
	public Message_A pop() {
		return _Messages.poll();
	}
	
	public int size() {
		return _Messages.size();
	}
	
	private ArrayDeque<Message_A> _Messages;
}